Omplus.base.define(Omplus.controllers.Controller, {
    omplusName:"transactionsController"
});


/**
 * ******************************************************************
 * Player Search
 * *****************************************************************
 */

Omplus.base.define(Omplus.models.Model, {
    omplusName:"TransactionSearch",
    controller:"transactionsController",
    value:{
        "player_id":{
            omplusType:"Number"
        },
        "email":{
            omplusType:"String"
        },
        "nick_name":{
            omplusType:"String"
        },
        "date_from":{
            omplusType:"DateTime"
        },
        "date_to":{
            omplusType:"DateTime"
        },
        "amount_from":{
            omplusType:"Number"
        },
        "amount_to":{
            omplusType:"Number"
        },
        "only_first":{
            omplusType:"Boolean"
        },
        delta:{
            omplusType:"Number",
            value:5
        },
        start:{
            omplusType:"Number",
            value:0
        }
    }
});

Omplus.models.TransactionSearchModelProto = Omplus.base.extend(Omplus.models.Object, {
    omplusType:"TransactionSearchModelProto",
    value:{
        "transaction_status":{
            omplusType:"String"
        },
        "transaction_type":{
            omplusType:"String"
        },
        "player_id":{
            omplusType:"Number"
        },
        "nickname":{
            omplusType:"String"
        },
        "deposit_type_name":{
            omplusType:"String"
        },
        "transaction_start":{
            omplusType:"DateTime"
        },
        "transaction_end":{
            omplusType:"DateTime"
        },
        "internal_id":{
            omplusType:"String"
        },
        "transaction_id":{
            omplusType:"Number"
        }
    }
});

Omplus.base.define(Omplus.models.Model, {
    omplusName:"TransactionSearchResults",
    controller:"transactionsController",
    value:{
        transactions:{
            omplusType:"Array",
            omplusProto:"TransactionSearchModelProto"
        },
        total:{
            omplusType:"Number"
        }
    }
});

Omplus.models.TransactionProto = Omplus.base.extend(Omplus.models.Model, {
    omplusType:"TransactionProto",
    value:{
        "transaction_status":{
            omplusType:"String",
            nullable: true
        },
        "internal_id":{
            omplusType:"String",
            nullable: true
        },
        "amount":{
            omplusType:"String",
            nullable: true
        },
        "player_id":{
            omplusType:"Number",
            nullable: true
        },
        "transaction_type":{
            omplusType:"String",
            nullable: true
        },
        "email":{
            omplusType:"String",
            nullable: true
        },
        "nick_name":{
            omplusType:"String",
            nullable: true
        },
        "transaction_id":{
            omplusType:"Number",
            nullable: true
        },
        "transaction_start":{
            omplusType:"DateTime",
            nullable: true
        },
        "transaction_end":{
            omplusType:"DateTime",
            nullable: true
        }
    }
});

Omplus.base.define(Omplus.models.SingleChooser, {
    omplusName:"transactionChooser",
    controller:"transactionsController",
    omplusProto:"TransactionProto"
});

Omplus.views.OpeningTransactionTabView = Omplus.base.extend(Omplus.views.OpeningTabView, {
    omplusType:"OpeningTransactionTabView",
    layout:{
        omplusType:"VerticalLayout",
        width: "300px"
    },
    controller:"transactionsController",
    components:[
        {
            //Transaction status
            model:"transactionChooser.current.transaction_status",
            labelModel:"Assets.list.status_label.localValue",
            inputType:"Label"
        },
        {
            model:"transactionChooser.current.transaction_type",
            labelModel:"Assets.list.type_label.localValue",
            inputType:"Label"
        },
        {
            model:"transactionChooser.current.amount",
            labelModel:"Assets.list.amount_label.localValue",
            inputType:"Label"
        },
        {
            model:"transactionChooser.current.player_id",
            labelModel:"Assets.list.player_id_label.localValue",
            inputType:"Label"
        },
        {
            model:"transactionChooser.current.email",
            labelModel:"Assets.list.email_label.localValue",
            inputType:"Label"
        },
        {
            model:"transactionChooser.current.nick_name",
            labelModel:"Assets.list.nick_name_label.localValue",
            inputType:"Label"
        },
        {
            model:"transactionChooser.current.transaction_id",
            labelModel:"Assets.list.transaction_id_label.localValue",
            inputType:"Label"
        },
        {
            model:"transactionChooser.current.transaction_start",
            labelModel:"Assets.list.transaction_start_label.localValue",
            inputType:"Label"
        },
        {
            model:"transactionChooser.current.transaction_end",
            labelModel:"Assets.list.transaction_end_label.localValue",
            inputType:"Label"
        }
    ]
});

Omplus.base.define(Omplus.views.ManagementPanel, {
    omplusName:"transactionsPanel",
    controller:"transactionsController",
    renderTo:"managements",
    models:{
        chooser:"transactionChooser",
        search:"TransactionSearch",
        searchResult:"TransactionSearchResults",
        searchResultList:"transactions",
        forDisplay:"internal_id"
    },
    views:{
        chooser:{
            title:"Assets.list.transactions_label.localValue",
            components:[
                {
                    omplusName:"transactionTabs",
                    omplusType:"OpeningTabPanel",
                    omplusProto:"OpeningTransactionTabView",
                    controller:"transactionsController",
                    model:"transactionChooser",
                    showModel:"internal_id"
                }
            ]
        },
        search:[
            {
                // Player Id
                model:"TransactionSearch.player_id",
                labelModel:"Assets.list.player_id_label.localValue"
            },
            {
                // Email
                model:"TransactionSearch.email",
                labelModel:"Assets.list.email_label.localValue"
            },
            {
                // nick_name
                model:"TransactionSearch.nick_name",
                labelModel:"Assets.list.nick_name_label.localValue"
            },
            {
                // Date of transaction from
                model:"TransactionSearch.date_from",
                labelModel:"Assets.list.from_label.localValue",
                inputType:"Datepicker",
                isTo:true
            },
            {
                // Date of transaction to
                model:"TransactionSearch.date_to",
                labelModel:"Assets.list.to_label.localValue",
                inputType:"Datepicker",
                isTo:true
            },
            {
                // Amount from
                model:"TransactionSearch.amount_from",
                labelModel:"Assets.list.amount_from_label.localValue"
            },
            {
                // Amount from
                model:"TransactionSearch.amount_to",
                labelModel:"Assets.list.amount_to_label.localValue"
            },
            {
                // Banned
                model:"TransactionSearch.only_first",
                labelModel:"Assets.list.only_first_label.localValue",
                inputType:"CheckBox",
                labelWidth:"80%",
                inputWidth:"20%"
            },
            {
                // Per page
                inputType:"Select",
                model:"PerPages",
                showModel:"number",
                current:"forTransactions",
                controller:"languageController",
                labelModel:"Assets.list.label_per_page.localValue",
                perPage:true
            },
            {
                // Search button
                inputType:"Button",
                controller:"languageController",
                model:"Assets.list.label_search_button.localValue",
                cssClasses:["search-button"],
                labelWidth:"0%",
                inputWidth:"100%",
                searchButton:true
            }
        ],
        searchResult:[
            {
                labelModel:"Assets.list.status_label.localValue",
                width:"170px",
                omplusType:"Label",
                model:"transaction_status"
            },
            {
                labelModel:"Assets.list.internal_id_label.localValue",
                width:"150px",
                omplusType:"Label",
                model:"internal_id"
            },
            {
                labelModel:"Assets.list.type_label.localValue",
                width:"100px",
                omplusType:"Label",
                model:"transaction_type"
            },
            {
                labelModel:"Assets.list.player_id_label.localValue",
                width:"80px",
                omplusType:"Label",
                model:"player_id"
            },
            {
                labelModel:"Assets.list.nick_name_label.localValue",
                width:"150px",
                omplusType:"Label",
                model:"nickname"
            },
            {
                labelModel:"Assets.list.method_label.localValue",
                width:"100px",
                omplusType:"Label",
                model:"deposit_type_name"
            },

            {
                omplusType:"Button",
                model:"Assets.list.details_label.localValue",
                width:"180px",
                controller:"languageController",
                getDetails:true,
                errorable:false
            }
        ]
    }
});